import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;

import java.util.SortedSet;
import java.util.TreeSet;

@Slf4j
public class SortSetTest {
    public static void main(String[] args) throws JsonProcessingException {
        SortedSet<Integer> sortedSet = new TreeSet<>();
        sortedSet.add(2);
        sortedSet.add(5);
        sortedSet.add(3);
        log.info(sortedSet.getClass() + sortedSet.toString());

        ObjectMapper om = new ObjectMapper();
        String json = om.writeValueAsString(sortedSet);
        log.info("Json is : {}", json);

        sortedSet = om.readValue(json, new TypeReference<>() {
        });
        log.info(sortedSet.getClass() + sortedSet.toString());
    }
}
